<?php

namespace App\Containers\AppSection\Log\Tasks;

use App\Containers\AppSection\Log\Data\Repositories\LogRepository;
use App\Ship\Criterias\OrderByCreationDateDescendingCriteria;
use App\Ship\Parents\Tasks\Task;

class GetAllLogsTask extends Task
{
    protected LogRepository $repository;

    public function __construct(LogRepository $repository)
    {
        $this->repository = $repository;
    }

    public function run()
    {
        return $this->repository->paginate();
    }

    public function forProfile($profileId): self
    {
        $this->repository->whereHas('profile', function ($query) use ($profileId) {
            $query->where('id', $profileId);
        });

        return $this;
    }
}
